#pragma once
#include "ArchiveCallback.h"

class C7zMgrArchive
	: public I7zMgrArchive
{
	enum Mode_7zOpen
	{
		FCreate,
		FUpdate,
	};
public:
	C7zMgrArchive(void);
	~C7zMgrArchive(void);
	int		GetVersion(){return 1;}
	void	Release(){delete this;}

	bool	Open(const wchar_t* chPath,size_t iOffset = 0);
	
	void	Close();

	int		GetFileNum();

	bool	GetFileName(int ,_7zFileInfo&);

	bool	ExtractFile(int iIndex = -1,const wchar_t* _path = NULL, pfnGetExtractPath pfn = NULL,void* param = NULL);

	bool	ArchiveFiles(const wchar_t* _path);
private:
	bool	SaveArchive(CObjectVector<CDirItem>& object);
	FString GetTmpFile();
	bool	ReOpenFile();
	void	SaveTmpFile(bool bOK);
	void	GetEnumFile(const FString& root,FString path,CObjectVector<CDirItem>& object);
private:
	IInArchive*							m_ptrInArchive;
	IOutArchive*						m_ptrOutArchive;

	Mode_7zOpen							m_openMode;
	FString								m_FsPath;
	size_t								m_iOffSet;
};